/**
 * Created by zhouli on 18/9/4
 * Email li.zhou@huilianyi.com
 */
import config from 'config';
import httpFetch from 'share/httpFetch';
import errorMessage from 'share/errorMessage';
import EFService from 'containers/enterprise-manage/extend-field/extend-field.service';

export default {
  //获取表单类型
  getWidgetList(params) {
    return new httpFetch.get(config.baseUrl + '/api/form/gui/widgets/all', params)
        .catch((err) => {
          errorMessage(err.response);
          throw err;
        })
  },
  //获取扩展字段表单：公司扩展字段
  getCustomForm() {
    let params = {
      formCode:"company_attach_form "
    };
    return httpFetch.get(config.baseUrl + '/api/custom/forms/by/form/code',params)
        .catch((err) => {
          errorMessage(err.response);
          throw err;
        })
  },
  //创建公司信息扩展字段表单
  createCustomForm: function (form) {
    return httpFetch.post(config.baseUrl + '/api/company/v2/custom/forms', form)
        .catch((err) => {
          errorMessage(err.response);
          throw err;
        })
  },
  //保存表单
  updateCustomForm(form) {
    return EFService.updateCustomForm(form)
        .catch((err) => {
          throw err;
        })
  },
  //新 创建公司扩展字段表单 （第一次创建时使用）
  createCompanyCustomForm: function (form) {
    return httpFetch.post(config.baseUrl + '/api/company/custom/forms', form)
        .catch((err) => {
          errorMessage(err.response);
          throw err;
        })
  },

}
